package com.open.capacity.tenant.dao.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 超级管理员用户表实体类--admin
 * @program: open-capacity-platform
 * @author: GuoGaoJu
 * @create: 2023-03-23
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("admin")
public class Admin implements UserDetails {

    @TableId(value = "id",type = IdType.ASSIGN_ID)
    private Long id;

    private String username;

    private String password;

    // 用户所有权限
    private List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();

    public Collection<? extends GrantedAuthority> getAuthorities() {

        return authorities;
    }

    //是否账号不过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    //是否账号不被锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    //是否凭证（密码）不过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    //是否可用
    @Override
    public boolean isEnabled() {
        return true;
    }
}
